Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix boolean short-circuit diagnostic handling #719

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jbardin
Copy link
Member

@jbardin jbardin commented Dec 17, 2024

Follow up to #713.

A couple boolean expression tests were passing because diagnostics were accidentally dropped when there was no short-circuit return. Add a positive test for the diagnostics and make sure they are always collected from both sides of the expression.

The logic to drop diagnostics needed to be within the short-circuit implementations, where a good LHS unknown value (one without any errors) prevents further evaluation allowing us to optimistically skip the RHS diagnostics. This can be confusing, because the logic looked correct, but we need to remember that cty/hcl return an unknown value when faced with errors too, and part of the short-circuit logic is to selectively handle errors when possible.

There was no test looking for dropped diagnostics when boolean opts
don't short-circuit. The missing diagnostics were what made some of the
tests from the original PR pass through, so a correction to that will
follow.
Drop RHS diagnostics when bot boolean op expression values are unknown.
This allows skipping an evaluation error on the RHS in case we can
short-circuit when the LHS is known.
@jbardin jbardin requested a review from a team December 17, 2024 00:24
@jbardin jbardin requested a review from a team as a code owner December 17, 2024 00:24
@jbardin
Copy link
Member Author

jbardin commented Dec 19, 2024

@hashicorp/team-ip-compliance

Copy link
Contributor

@mukeshjc mukeshjc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants